package pe.com.ztaxi.taxis.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pe.com.ztaxi.taxis.model.OrdenServicio;
import pe.com.ztaxi.taxis.service.OrdenServicioService;

@PreAuthorize("hasRole('ROLE_ADMIN')") 
@Controller
public class MonitoreoController {

	@Autowired
	private OrdenServicioService ordenServicioService;
	
	@RequestMapping(value = "/getAlertasEmergentes", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)  
	public @ResponseBody String[] getAlertasEmergentes(){
		List<OrdenServicio> ordenesServicio = ordenServicioService.buscarOrdenesPendientesEnProceso();
		return ordenServicioService.getAlertasEmergentes(ordenesServicio);	
	}
	
}
